package com.capgemini.business.controller;

import com.capgemini.business.mapper.dataobject.ProjectTeamMembers;
import com.capgemini.business.service.ProjectTeamMembersService;
import com.capgemini.commons.response.Response;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/project-team-members")
public class ProjectTeamMembersController {

    @Resource
    private ProjectTeamMembersService projectTeamMembersService;

    @GetMapping("/list")
    public Response<List<ProjectTeamMembers>> list() {
        return Response.success(projectTeamMembersService.list());
    }

    @GetMapping("/get/{id}")
    public Response<ProjectTeamMembers> getById(@PathVariable Integer id) {
        return Response.success(projectTeamMembersService.findById(id));
    }


    @PostMapping("/add")
    public Response<String> save(@RequestBody ProjectTeamMembers employee) {
        projectTeamMembersService.save(employee);
        return Response.success("success");
    }

    @PostMapping("/update")
    public Response<String> update(@RequestBody ProjectTeamMembers employee) {
        projectTeamMembersService.update(employee);
        return Response.success("success");
    }

    @DeleteMapping("/delete/{id}")
    public Response<String> delete(@PathVariable Integer id) {
        projectTeamMembersService.delete(id);
        return Response.success("success");
    }
}
